﻿
--ClientHeartbeatList-----------------
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[ClientHeartbeatList]'))
DROP VIEW [dbo].[ClientHeartbeatList]
GO

CREATE VIEW [dbo].[ClientHeartbeatList]
AS
	SELECT 
		CH.[Key] AS 'Key',
		MC.[Name] AS 'Name',
		CH.[ClientKey] AS 'ClientKey',
		CH.[CreatedStamp] AS 'Stamp'
	FROM [dbo].[ClientHeartbeat] AS CH
	LEFT OUTER JOIN [dbo].[MonitorClient] AS MC
	ON CH.[ClientKey] = MC.[Key]
GO

/*
--TaskExecutionRecordList-----------------
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[TaskExecutionRecordList]'))
DROP VIEW [dbo].[TaskExecutionRecordList]
GO

CREATE VIEW [dbo].[TaskExecutionRecordList]
AS
	SELECT 
		MTER.[Key] AS 'RecordKey', 
		MTER.[TaskKey] AS 'TaskKey', 
		MTER.[IsSuccess] AS 'IsSuccess',
		MTER.[Exception] AS 'Exception', 
		MTER.[CreatedStamp] AS 'RecordCreatedStamp',
		MT.[ExecutionType] AS 'TaskExecutionType',
		MT.[Name] AS 'TaskName',
		MT.[DomainScopeCode] AS 'DomainScopeCode',
		DS.[Name] AS 'DomainScopeName',
		MT.[ThirdPartyIdentity] AS 'TaskThirdPartyIdentity',
		MC.[Name] AS 'ClientName'
	FROM [dbo].[TaskExecutionRecord] AS MTER
	LEFT OUTER JOIN [dbo].[MonitorTask] AS MT
	ON MT.[Key] = MTER.[TaskKey]
	LEFT OUTER JOIN [dbo].[MonitorClient] AS MC
	ON MT.AssignedToClientKey = MC.[Key]
	LEFT OUTER JOIN [dbo].[DomainScope] AS DS
	ON DS.[Code] = MT.[DomainScopeCode]
GO
*/